/*
 * PdfBase.h
 *
 *  Created on: Sep 11, 2008
 *      Author: pasha
 */

#ifndef PDFBASE_H_
#define PDFBASE_H_


//#include <vector>
#include <list>
//#include <string>
#include "hpdf.h"
#include "PdfPage.h"


#include "IPhysicFormat.h"


namespace dasco
{
namespace report
{

typedef std::list<PdfPage*> PageList;

//! \class PdfBase
//! \brief PDF document
class DLL_EXPORT PdfBase
	:public IPhysicFormat
	,protected PageList
{
	friend class GridPdf;
public:
	static const float A4_width, A4_hight;

	PdfBase(const char* = "root");
	virtual ~PdfBase();

	// IPhysicFormat iface
	void renderGrid(const IGrid*);
	void save(const char*) throw (IIOException);
	void load(const char*,IGrid***,unsigned*) throw (IIOException) {};
	//end IPhysicFormat iface

	int getPdfSize();
	void getPdfByte(unsigned char*,unsigned* realSize);

	HPDF_Outline createOnline(const char*,const HPDF_Outline&);
	HPDF_Outline createRootOnline(const char* text){return createOnline(text,root);}

	unsigned measureText(const char*,float = 14.0f,float = A4_width) const ;

	void numerationPage(const char* = "page");
	void currentDate(const char* = NULL);
	void setFIRdemo();


protected:
	const HPDF_Doc  pdf;
	const HPDF_Encoder encoder;
	const HPDF_Outline root;
	HPDF_Font font;
	//HPDF_Font ean13font;
	HPDF_Destination dst;
	//int cntPage;

	PdfPage* getPage();
	void downloadQuickLzFontTTF(HPDF_Font&,const unsigned char*, const unsigned, const char* = DEFAULT_PDF_ENCODE);

public:
	//static void ean13_matrix_IDAutomation(char*,char*,unsigned);
};

}} //end namespace dasco::report

#endif /* PDFBASE_H_ */
